#!/bin/bash
SERVICE="nginx"
if ! systemctl is-active --quiet $SERVICE; then
  systemctl restart $SERVICE
  echo "$SERVICE 已重启" | mail -s "服务恢复" admin@example.com
fi